package com.dongluhitec.card.server.logfilter;


import java.lang.reflect.Method;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.dongluhitec.card.server.DongluServer;

public class LoggerMethodInterceptor implements MethodInterceptor {
	private static final Logger logger = LoggerFactory.getLogger(DongluServer.class);

	public Object invoke(MethodInvocation invocation) throws Throwable {
		Method method = invocation.getMethod();
		String methodName = method.getName();
		long startTime = System.nanoTime();
		Object ret = invocation.proceed();
		long endTime = System.nanoTime();
		logger.info("[{}]类的方法[{}]执行完成。耗时：[{}]纳秒",method.getDeclaringClass().getName(), methodName, (endTime - startTime));
		return ret;
	}
}
